﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HidesaburoDotNET.Core.Detecctors
{
    public class IipeikoDetector : YakuDetector
    {
        public override Yaku CheckYaku(AgariTehai agariTehai)
        {
            if (!agariTehai.Menzen)
            {
                return new Yaku();
            }
            int n = 0;
            HaiType ht = HaiType.None;
            int hn = 0;
            for (int i = 0; i < agariTehai.Mentsu.Count - 1; i++)
            {
                for (int j = i + 1; j < agariTehai.Mentsu.Count; j++)
                {
                    if (agariTehai.Mentsu[i].Type == MentsuType.Syuntsu_A)
                    {
                        if (agariTehai.Mentsu[i] == agariTehai.Mentsu[j])
                        {
                            if (agariTehai.Mentsu[i].Hais[0].Type == ht && agariTehai.Mentsu[i].Hais[0].Number == hn)
                            {
                                break;
                            }
                            else
                            {
                                n++;
                                ht = agariTehai.Mentsu[i].Hais[0].Type;
                                hn = agariTehai.Mentsu[i].Hais[0].Number;
                                break;
                            }
                        }
                    }

                }
            }
            if (n == 1)
            {
                return new Yaku(1,"イーペーコー");
            }
            else
            {
                return new Yaku();
            }

        }

        private Hai Hai()
        {
            throw new NotImplementedException();
        }
    }
}
